/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.openatom.ubml.model.vo.definition.collection;

import java.io.Serializable;
import org.openatom.ubml.model.common.definition.cef.collection.BaseList;
import org.openatom.ubml.model.vo.definition.common.ValueHelpConfig;

/**
 * The Collection Of The Help Config
 *
 * @ClassName: ValueHelpConfigCollection
 * @Author: Benjamin Gong
 * @Date: 2021/1/11 17:13
 * @Version: V1.0
 */
public class ValueHelpConfigCollection extends BaseList<ValueHelpConfig> implements Cloneable, Serializable {

    /**
     * 构造函数
     */
    public ValueHelpConfigCollection() {
        super();
    }

    /**
     * 获取指定ID的值帮助配置
     *
     * @param elementId Element标识
     * @return 值帮助配置
     */
    public final ValueHelpConfig getItem(String elementId) {
        for (ValueHelpConfig item : this) {
            if (item.getElementId().equals(elementId)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 批量添加值帮助配置
     *
     * @param items 值帮助配置集合
     */
    public final void addRange(ValueHelpConfig[] items) {
        for (ValueHelpConfig item : items) {
            super.add(item);
        }
    }

    /**
     * 批量添加值帮助配置
     *
     * @param items 值帮助配置集合
     */
    public final void addRange(Iterable<ValueHelpConfig> items) {
        for (ValueHelpConfig item : items) {
            add(item);
        }
    }

    /**
     * 克隆
     *
     * @return 值帮助配置集合的副本
     */
    @Override
    public final ValueHelpConfigCollection clone() {
        ValueHelpConfigCollection newCollection = new ValueHelpConfigCollection();
        for (ValueHelpConfig item : this) {
            super.add(item);
        }
        return newCollection;
    }

}
